<?php
session_start();
$_SESSION["previouspage"] = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];//remember the url of this page, used for redirect.

require_once 'include/config.lib.php';
require_once 'include/database.lib.php';
if(isset($_SESSION["accountNo"])){
	//user has logged in
		ConnectToDB();// Connect to the DB.
	
		$reportedUserID = $_SESSION["reportuserid"];
		
		$user = DBExecute("SELECT p.name as name FROM person p WHERE p.id = ?", array($reportedUserID));
		$reportedusername = $user->fetchAssocRow();
		
	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="third_party/jquery-ui-1.8.5/jquery-ui-1.8.5.custom.css" />
	<link rel="stylesheet" type="text/css" href="css/template.css" />
	<link rel="stylesheet" type="text/css" href="css/person_view.css" />
	<link rel="stylesheet" type="text/css" href="css/network_styles.css" />
	<script type="text/javascript" src="http://www.google.com/jsapi"></script>
	<script type="text/javascript" src="third_party/jit.js"></script>
	<script type="text/javascript" src="third_party/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="third_party/jquery-ui-1.8.5/jquery-ui-1.8.5.custom.min.js"></script>
	<script type="text/javascript" src="js/system.js"></script>
	
	<script language="javascript" src="js/bluff/js-class.js" type="text/javascript"></script>
	<script language="javascript" src="js/bluff/bluff-min.js" type="text/javascript"></script>
	
	<script type='text/javascript'>
	}
	
	</script>
	
	<title>Report Abuse - CoRAL</title>
	</head>
		<body onload="OnLoad();">
		
		<?php //to determine whether a user has logged in or not, which will output different buttons
		if(isset($_SESSION["accountNo"])){	
			$inorout = "controller/logout.php";	$display = "Log out";}
		else{
			$inorout = "login.php";	$display = "Log in";
		}
		?>
		
			<div id="body-wrapper">
			<?php include_once 'static/header.php'; ?>
			
				<div id="body">
					<div id="report" class="section"> <!-- Form for user to fill out detailing user abuse -->
						<form id="reportUser" action=controller/emailuserreport.php method="post" enctype="multipart/form-data">
							<th><font size="5"> <b> Reporting user "<?php echo htmlentities($reportedusername['NAME']); ?>" for abuse:  </b></font></th>
							<br/>
							<th><font size="3">Please describe the event in question, and why it was deemed offensive in 255 characters or less</font></th>
							<table class="info">
								<th><font size="1">Note that the fields marked with a '*' are required</font></th>
								<br/>
								<br/>
								<tr><th>Abusive event in question<font color="red">*</font>:</th><td><textarea name="event" rows="5" cols="60" wrap="physical" maxlength="255"</textarea></td></tr>
								<tr><th>Why was this event considered offensive?<font color="red">*</font>:</th><td><textarea name="reason" rows="5" cols="60" wrap="physical" maxlength="255"</textarea></td></tr>
								<input type="hidden" name="userID" value= <?php echo $reportedUserID; ?> >
								<input type="hidden" name="userName" value= <?php echo htmlentities($reportedusername['NAME']); ?> >
							</table>
							<input type="submit" class="button" value="Report User for Abuse" />
						</form>
					</div>
				</div>
			<?php include_once 'static/footer.html'; ?>
			</div>
		</body>
	</html>
<?php
}
else{//user hasn't logged in -> reroute to login page
	$_SESSION["errmsg"] = "You didn't log in.";
	echo "<HTML><META http-equiv=\"refresh\" content=\"0; url=login.php\"></HTML>";//redirect to the login page
}
?>